package dao.jpa;

import java.util.List;

import vo.UserTopic;
import dao.UserTopicDAO;

public class UserTopicDAOJpaImpl extends GenericDaoJpaImpl<UserTopic, Long> implements UserTopicDAO {

	public UserTopicDAOJpaImpl() {
		super(UserTopic.class);
	}

	public List<UserTopic> findAll() {
		return super.executeFinder("UserTopic.findAll");
	}
	public boolean isExiste(long userId,long topicId) {
		if(super.executeSingleFinder("UserTopic.findByUserIdTopicId",userId,topicId)==null)
			return false;
		else return true;
	}

	public List<UserTopic> findNonSubUsers(long topicId) {
		return super.executeFinder("UserTopic.findNonSubUsers",topicId);
	}

	public List<UserTopic> findByUserId(long userId) {
		return super.executeFinder("UserTopic.findByUserId",userId);
	}

	public int findCountByUserId(long userId) {
		return super.executeFinder("UserTopic.findByUserId",userId).size();
	}

	public List<UserTopic> findByTopicId(long topicId) {
		return super.executeFinder("UserTopic.findByTopicId",topicId);
	}

	public List<UserTopic> findByTopicIdUserRole(long topicId) {
		return super.executeFinder("UserTopic.findByTopicIdUserRole",topicId);
	}

	public UserTopic getById(long id) {
		return super.read(id);
	}

	public UserTopic getByTopicIdUserId(long topicId,long userId) {
		return super.executeSingleFinder("UserTopic.findByUserIdTopicId",userId,topicId);
	}

	public void update(long id) {
		UserTopic userTopic = super.read(id);
		super.update(userTopic);
	}

	public void delete(long id)	{
		UserTopic userTopic= super.read(id);
		super.delete(userTopic);
	}

}
